<template>
	<view>
		<!-- 普通弹窗 background-color="#ffffff" -->
		<uni-popup :is-mask-click="false" ref="popup" type="center">
			<view>
				<view class="w-pop" style="background: #ffffff;">
					<view class="base-title">修改积分获取方式</view>
					<view class="item-box">
						<view class="label-box">{{ text }}</view>
						<view class="flex item-center">
							<input type="number" placeholder="请输入" class="inp-box" v-model="num">{{str === 'shareDailyLimit'?'次':'积分'}}
						</view>
					</view>
					<view class="flex item-center btn-box">
						<view class="cancal-btn" @click="showPop(false)">取消</view>
						<view class="submit-btn" @click="submit">确定</view>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script setup>
	import {ref,reactive,defineEmits,computed} from 'vue';
	
	const emit = defineEmits(['confirm'])
	const num = ref('')
	const text = ref('')
	let str = ''
	const popup = ref()
	const showPop = async (value, data) => {
		if (value) {
			if(data){
				num.value = data.value
				text.value = data.text
				str = data.str
			}else{
				num.value = ''
				text.value = ''
			}
			popup.value && popup.value.open('center')
		} else {
			popup.value && popup.value.close()
		}
	}
	const submit = async () => {
		if (!num.value && num.value!=0) {
			uni.showToast({
				icon: 'none',
				title: `请填写${str==='shareDailyLimit'?'次数':'积分'}`
			})
			return
		}
		emit('confirm', str, num.value)
	}
	defineExpose({
		showPop
	})
</script>

<style scoped lang="scss">
	.pick {
		font-size: 40px;
		color: rgba(51, 51, 51, .61);
	}

	.w-pop {
		background: #fffff;
		border-radius: 8px;
		padding: 20px 0px 0 0px;
		width: 300px;
	}

	.base-title {
		font-size: 20px;
		font-weight: 600;
		line-height: 28px;
		margin-bottom: 10px;
		text-align: center;
	}

	.item-box {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 20px;
	}

	.label-box {
		font-size: 14px;
		font-weight: 600;
		line-height: 20px;
		color: rgba(51, 51, 51, 1);
		margin: 6px 0;
	}

	.inp-box {
		background: rgba(245, 245, 245, 1);
		height: 32px;
		border-radius: 12px;
		padding: 0 10px;
		line-height: 32px;
		border: 1px solid rgba(245, 245, 245, 1);
		width: 120px;
		&.special{
			width: 67px;
			height: 25px;
			line-height: 25px;
		}
		&.unactive {
			border-color: #FA4543;
		}
	}

	.btn-box {
		border-top: 1px solid rgba(0, 0, 0, 0.1);
		margin-top: 20px;
		line-height: 40px;
	}

	.cancal-btn {
		width: 50%;
		font-family: PingFang SC;
		font-size: 16px;
		font-weight: 400;
		text-align: center;
		color: rgba(51, 51, 51, 0.6);
		border-right: 1px solid rgba(0, 0, 0, 0.1);
	}

	.submit-btn {
		width: 50%;
		font-family: PingFang SC;
		font-size: 16px;
		font-weight: 400;
		text-align: center;
		color: rgba(250, 69, 67, 1);
	}
</style>
